home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Microsoft Plateform / Visual Basic 5.0 / Msvb50.ace / msvb50 / MSVB50 / VB / SAMPLES / VISDATA / NEWATTCH.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-10-16  |  7.2 KB  |  240 lines

  1. VERSION 5.00
  2. Begin VB.Form frmNewAttach 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "New Attached Table"
  5.    ClientHeight    =   3465
  6.    ClientLeft      =   4830
  7.    ClientTop       =   5325
  8.    ClientWidth     =   4245
  9.    Height          =   3930
  10.    HelpContextID   =   2016135
  11.    Icon            =   "NEWATTCH.frx":0000
  12.    Left            =   4770
  13.    LinkTopic       =   "Form1"
  14.    LockControls    =   -1  'True
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   3465
  18.    ScaleWidth      =   4245
  19.    ShowInTaskbar   =   0   'False
  20.    StartUpPosition =   1  'CenterOwner
  21.    Top             =   4920
  22.    Width           =   4365
  23.    Begin VB.ComboBox cboConnect 
  24.       Height          =   315
  25.       ItemData        =   "NEWATTCH.frx":030A
  26.       Left            =   120
  27.       List            =   "NEWATTCH.frx":030C
  28.       TabIndex        =   5
  29.       Top             =   1560
  30.       Width           =   3975
  31.    End
  32.    Begin VB.TextBox txtDatabase 
  33.       Height          =   285
  34.       Left            =   120
  35.       TabIndex        =   3
  36.       Top             =   960
  37.       Width           =   3975
  38.    End
  39.    Begin VB.CheckBox chkExclusive 
  40.       Caption         =   "AttachExclusive"
  41.       Height          =   225
  42.       Left            =   2160
  43.       MaskColor       =   &H00000000&
  44.       TabIndex        =   9
  45.       Top             =   2520
  46.       Width           =   1785
  47.    End
  48.    Begin VB.CheckBox chkSavePassword 
  49.       Caption         =   "AttachSavePWD"
  50.       Height          =   225
  51.       Left            =   120
  52.       MaskColor       =   &H00000000&
  53.       TabIndex        =   8
  54.       Top             =   2520
  55.       Width           =   1740
  56.    End
  57.    Begin VB.CommandButton cmdCancel 
  58.       Cancel          =   -1  'True
  59.       Caption         =   "&Cancel"
  60.       Height          =   435
  61.       Left            =   2160
  62.       MaskColor       =   &H00000000&
  63.       TabIndex        =   11
  64.       Top             =   2880
  65.       Width           =   1905
  66.    End
  67.    Begin VB.CommandButton cmdAttach 
  68.       Caption         =   "&Attach"
  69.       Default         =   -1  'True
  70.       Enabled         =   0   'False
  71.       Height          =   435
  72.       Left            =   120
  73.       MaskColor       =   &H00000000&
  74.       TabIndex        =   10
  75.       Top             =   2880
  76.       Width           =   1905
  77.    End
  78.    Begin VB.ComboBox cboTableName 
  79.       Height          =   315
  80.       Left            =   120
  81.       TabIndex        =   7
  82.       Top             =   2160
  83.       Width           =   3975
  84.    End
  85.    Begin VB.TextBox txtAttachName 
  86.       Height          =   285
  87.       Left            =   120
  88.       TabIndex        =   1
  89.       Top             =   360
  90.       Width           =   3975
  91.    End
  92.    Begin VB.Label lblLabels 
  93.       AutoSize        =   -1  'True
  94.       Caption         =   "Database Name: "
  95.       Height          =   195
  96.       Index           =   1
  97.       Left            =   105
  98.       TabIndex        =   2
  99.       Top             =   720
  100.       Width           =   1245
  101.    End
  102.    Begin VB.Label lblLabels 
  103.       AutoSize        =   -1  'True
  104.       Caption         =   "Table to Attach: "
  105.       Height          =   195
  106.       Index           =   3
  107.       Left            =   120
  108.       TabIndex        =   6
  109.       Top             =   1920
  110.       Width           =   1215
  111.    End
  112.    Begin VB.Label lblLabels 
  113.       AutoSize        =   -1  'True
  114.       Caption         =   "Connect String: "
  115.       Height          =   195
  116.       Index           =   2
  117.       Left            =   105
  118.       TabIndex        =   4
  119.       Top             =   1320
  120.       Width           =   1170
  121.    End
  122.    Begin VB.Label lblLabels 
  123.       AutoSize        =   -1  'True
  124.       Caption         =   "Attachment Name: "
  125.       Height          =   195
  126.       Index           =   0
  127.       Left            =   120
  128.       TabIndex        =   0
  129.       Top             =   105
  130.       Width           =   1395
  131.    End
  132. Attribute VB_Name = "frmNewAttach"
  133. Attribute VB_Base = "0{6F48C4C7-C9E4-11CF-9ED2-00AA00574745}"
  134. Attribute VB_GlobalNameSpace = False
  135. Attribute VB_Creatable = False
  136. Attribute VB_TemplateDerived = False
  137. Attribute VB_PredeclaredId = True
  138. Attribute VB_Exposed = False
  139. Attribute VB_Customizable = False
  140. Option Explicit
  141. '>>>>>>>>>>>>>>>>>>>>>>>>
  142. Const FORMCAPTION = "New Attached Table"
  143. Const BUTTON1 = "&Attach"
  144. Const BUTTON2 = "&Cancel"
  145. Const Label1 = "Attachment &Name:"
  146. Const Label2 = "&Database Name:"
  147. Const LABEL3 = "C&onnect String:"
  148. Const LABEL4 = "&Table to Attach:"
  149. Const CHECK1 = "AttachSave&PWD"
  150. Const CHECK2 = "Attach&Exclusive"
  151. '>>>>>>>>>>>>>>>>>>>>>>>>
  152. Dim mbAdded As Boolean
  153. Private Sub cmdCancel_Click()
  154.   If mbAdded Then
  155.     'they added some so we need to refresh the table list
  156.     RefreshTables Nothing
  157.   End If
  158.   Unload Me
  159. End Sub
  160. Sub Form_Load()
  161.   Me.Caption = FORMCAPTION
  162.   cmdAttach.Caption = BUTTON1
  163.   cmdCancel.Caption = BUTTON2
  164.   lblLabels(0).Caption = Label1
  165.   lblLabels(1).Caption = Label2
  166.   lblLabels(2).Caption = LABEL3
  167.   lblLabels(3).Caption = LABEL4
  168.   chkSavePassword.Caption = CHECK1
  169.   chkExclusive.Caption = CHECK2
  170.   cboConnect.AddItem "Access MDB"
  171.   cboConnect.AddItem "Dbase III"
  172.   cboConnect.AddItem "Dbase IV"
  173.   cboConnect.AddItem "FoxPro 2.0"
  174.   cboConnect.AddItem "FoxPro 2.5"
  175.   cboConnect.AddItem "FoxPro 2.6"
  176.   cboConnect.AddItem "Paradox 3.X"
  177.   cboConnect.AddItem "Paradox 4.X"
  178.   cboConnect.AddItem "Excel 5.0"
  179.   cboConnect.AddItem "Excel 4.0"
  180.   cboConnect.AddItem "Excel 3.0"
  181.   cboConnect.AddItem "Text Files"
  182.   cboConnect.AddItem "ODBC"
  183.   cboConnect.ListIndex = 0
  184. End Sub
  185. Private Sub txtAttachName_Change()
  186.   cmdAttach.Enabled = Len(txtAttachName.Text) > 0
  187.   If cboTableName.ListCount > 0 Then cboTableName.Clear
  188. End Sub
  189. Private Sub cboConnect_Change()
  190.   cmdAttach.Enabled = Len(txtAttachName.Text) > 0
  191.   If cboTableName.ListCount > 0 Then cboTableName.Clear
  192. End Sub
  193. Private Sub cboTableName_DropDown()
  194.   Dim db As Database
  195.   Dim i As Integer
  196.   Dim sDataType As String       'data type string
  197.   Dim tdf As TableDef
  198.   On Error GoTo DDErr
  199.   Screen.MousePointer = vbHourglass
  200.   If cboTableName.ListCount = 0 Then
  201.     'fill in the list
  202.     sDataType = GetConnectStr()
  203.     If cboConnect.ListIndex = 0 Then
  204.       'special case for Microsoft Access mdb tables
  205.       Set db = gwsMainWS.OpenDatabase(vbNullString, 0, 0, sDataType)
  206.     Else
  207.       Set db = gwsMainWS.OpenDatabase(vbNullString, 0, 0, sDataType & ";" & cboConnect.Text)
  208.     End If
  209.     For Each tdf In db.TableDefs
  210.       If (tdf.Attributes And dbSystemObject) = 0 Then
  211.         cboTableName.AddItem tdf.Name
  212.       End If
  213.     Next
  214.   End If
  215.   Screen.MousePointer = vbDefault
  216.   Exit Sub
  217. DDErr:
  218.   ShowError
  219. End Sub
  220. Private Sub cmdAttach_Click()
  221.   frmAttachments.AddAttachment
  222.   mbAdded = True
  223. End Sub
  224. Public Function GetConnectStr() As String
  225.   On Error GoTo GCErr
  226.   Dim sTmp As String
  227.   If cboConnect.ListIndex = 0 Then
  228.     sTmp = ";"
  229.   Else
  230.     sTmp = cboConnect.Text & ";"
  231.   End If
  232.   If Len(txtDatabase.Text) > 0 Then
  233.     sTmp = sTmp & "database=" & txtDatabase
  234.   End If
  235.   GetConnectStr = sTmp
  236.   Exit Function
  237. GCErr:
  238.   ShowError
  239. End Function
  240.